package com.lshl.lingshang.http.lifecycle;

import android.widget.ImageView;

import androidx.databinding.BindingAdapter;
import androidx.lifecycle.MutableLiveData;

import com.lshl.lingshang.R;
import com.lshl.lingshang.ui.bean.TitleBean;
import com.lshl.lingshang.utils.ResLoaderUtils;

/**
 * Description：
 * Created on 2020/6/9
 * Author : 郭
 */
public final class TitleLiveData<T> extends MutableLiveData<T> {

    private TitleBean bean = new TitleBean();

    @BindingAdapter("android:src")
    public static void setSrc(ImageView view, int resId) {
        view.setImageResource(resId);
    }
    public void setTitleBar(boolean showLeft, String title) {
        if (showLeft) {
//            setSrc();
            bean.setResLeft(ResLoaderUtils.getDrawable(R.mipmap.arrow_left_black));

        }
        bean.setTitle(title);
        setValue((T) bean);
    }

    public void setTitleBar(boolean showLeft, String title,int resRight) {
        if (showLeft) {
            bean.setResLeft(ResLoaderUtils.getDrawable(R.mipmap.arrow_left_black));
        }
        bean.setResRight(resRight);
        bean.setTitle(title);
        setValue((T) bean);
    }


}
